<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/grsun" prefix="grsun"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta charset="utf-8" />
<meta name="description" content="Mailbox with some customizations as described in docs" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<%@ include file="/include/main_include.jsp"%>
<%@ include file="/include/form_include.jsp"%>
</head>
<body>
	<div class="modal-body" style="max-height: 716px;">
		<div id="divform" class="row mx-dialog-c bs_dialog open"> 
		   <form id="dataForm" class="form-horizontal" method="post"> 
			<div class="form-group col-lg-6 col-sm-6 col-xs-6">
		        <label class="control-label mx-group-title">id编码</label>
		        <div class="mx-group-control" style="height:33px;">
					<input id="itemid" name="itemid" type="text" class="width-100 mx-input-group" style="height:33px;" value="${pd.itemid}">
		        </div>
		    </div>
			<div class="form-group col-lg-6 col-sm-6 col-xs-6">
		        <label class="control-label mx-group-title">名称</label>
		        <div class="mx-group-control" style="height:33px;">
					<input id="title" name="title" type="text" class="width-100 mx-input-group" style="height:33px;" value="${pd.title}">
		        </div>
		    </div>
		    <div class="form-group col-lg-6 col-sm-6 col-xs-6">
		        <label class="control-label mx-group-title">级别</label>
		        <div class="mx-group-control" style="height:33px;">
		        		 <select id="level" name="level" class="width-100" style="height: 33px;">
									<option value="1">省</option>
									<option value="2">市</option>
									<option value="3">县</option>
						</select>
		        </div>
		    </div>
		    
		     <div class="form-group col-lg-6 col-sm-6 col-xs-6">
					<label class="control-label mx-group-title"><span class="require" style='color:red;font-size:16px'></span>父级</label>
					<div class="mx-group-control" style="height: 33px;">
						<span class="input-icon input-icon-right reftext mx-input-group width-100">
							<input type="text" class="form-control reftext-text" value="${pd.parentName }" id="parentName" NAME="parentName" readonly="readonly">
							<i class="ace-icon fa fa-search  bigger-120 reftext-search-button" id="agentChoose"></i>
							<input type="hidden" name="parentid" id="parentid" value="${pd.parentid }" />
						</span>
					</div>
			</div>
			 
		  </form>                  
		</div>
	</div>
	<script type="text/javascript">
	$(function() {
		$('#dataForm').form('load',{
			level:'${empty pd.level?1:pd.level}'
		});
		$('#parentName,#agentChoose').on('click', function() {
			grsunChooseWindow.chooseCityWindow.show(function(result) {
				$('#parentid').val(result.itemid);
				$('#parentName').val(result.text);
			});
		});
		
		$('#dataForm').validate({
			submitHandler : function(form) {
				var index = parent.layer.getFrameIndex(window.name);
				$.uitools.showLoading();//打开处理中遮罩层
				$.ajax({
					cache : true,
					type : "POST",
					url : rootpath + '/hhCity/save.do',
					data : $('#dataForm').serialize(),
					error : function(request) {
						$.uitools.hideLoading();//关闭处理中遮罩层
						layer.msg('系统异常！', {
							icon : 2,
							time : 1000
						}, function() {
							parent.layer.close(index);
						})
					},
					success : function(data) {
						$.uitools.hideLoading();//关闭处理中遮罩层
						if (data.code==0) {
							layer.msg('提交成功！', {
								icon : 1,
								time : 1000
							}, function() {
								parent.layer.close(index);
								//刷新列表
								parent.dataTable.datagrid('reload');
							})
						} else {
							layer.msg(data.msg, {
								icon : 2,
								time : 1000
							}, function() {
								parent.layer.close(index);
							})
						}
					}
				});
			},
			rules : {
				itemid : { required : true },
				title : { required : true },
				shortname : { required : true },
				level : { required : true ,number : true},
				rootid : { required : true },
				rootName : { required : true }
			},
			messages : {
				itemid : { required : '请输入' },
				title : { required : '请输入' },
				shortname : { required : '请输入' },
				level : { required : '请输入级别' },
				rootid : { required : '请输入' },
				rootName : { required : '请输入省名称' }
			},
			// 失去焦点时不执行验证
			onfocusout : false,
			// 错误提示，错误对象
			errorPlacement : function(error, element) {
				// 1.错误信息，2提示位置，3同时提示多个错误
				layer.tips(error[0].innerText, element, {
					// 错误信息可以同时提示多个，...
					tipsMore : true,
					tips : [ 3, '#D16E6C' ]
				});
			}
		});
	});
	</script>
</body>
</html>
